package org.dr.st_docker.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class beanTest {
    public static void main(String[] args) {
        //通过读取类路径下beans.xml文件，调用Spring接口
        ApplicationContext ac=new ClassPathXmlApplicationContext("bean.xml");

        //通过id获取bean，返回一个对象//默认无属性注入
        People people=(People)ac.getBean("people");
        //调用方法
        System.out.println(people);

        //属性注入
        People people2=(People)ac.getBean("people2");
        System.out.println(people2);

        //类型注入
        People people3=(People)ac.getBean("people3");
        System.out.println(people3);

        //类型注入
        People people4=(People)ac.getBean("people4");
        System.out.println(people4);

        //联合使用
        People people5=(People)ac.getBean("people5");
        System.out.println(people5);

        //工厂方式注入，非静态
        People people6=(People)ac.getBean("people6");
        System.out.println(people6);

        //工厂方式注入，静态
        People people7=(People)ac.getBean("people7");
        System.out.println(people7);

        //p命名
        People people8=(People)ac.getBean("people8");
        System.out.println(people8);

        //c命名
        People people9=(People)ac.getBean("people9");
        System.out.println(people9);

    }
}